﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Newtonsoft.Json;

namespace RestSemitaService.Controllers
{
    public class ValuesController : ApiController
    {
        // GET api/values
        public string Get()
        {
            //return new string[] { "value1", "value2" };
            string json = JsonConvert.SerializeObject(new string[] { "value1", "value2" });
            return json; 
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }
        class Product
        {
            public string Name { get; set; }
            public string status { get; set; }
            public DateTime Expiry { get; set; }
            public string[] Sizes { get; set; }
        }
        //class Product
        //{
        //    string Name;
        //    DateTime Expiry;
        //    string[] Sizes;
        //}

        //api/values?Name=apple&STATUS=yes
        public string Get(string name,string status)
        {

            Product product = new Product();
            //product.Name = "Apple";
            product.Name = name;
            product.status = status;
            product.Expiry = new DateTime(2008, 12, 28);
            product.Sizes = new string[] { "Small" };

            string json = JsonConvert.SerializeObject(product);
            //{
            //  "Name": "Apple",
            //  "Expiry": "2008-12-28T00:00:00",
            //  "Sizes": [
            //    "Small"
            //  ]
            //}
            return json;
        }

        // POST api/values
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}